package vip.source.pattern.part01.improve.service.impl;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import vip.source.pattern.part01.base.card.IQiYiCardService;
import vip.source.pattern.part01.improve.service.ICommodity;

import java.util.Map;

@Slf4j
public class CardCommodityService implements ICommodity {

    // 模拟注入
    private IQiYiCardService iQiYiCardService = new IQiYiCardService();

    @Override
    public void sendCommodity(
            String uId, String commodityId, String bizId, Map<String, String> extMap)
            throws Exception {
        String mobile = queryUserMobile(uId);
        iQiYiCardService.grantToken(mobile, bizId);
        log.info(
                "请求参数[爱奇艺兑换卡] => uId：{} commodityId：{} bizId：{} extMap：{}",
                uId,
                commodityId,
                bizId,
                JSON.toJSON(extMap));
        log.info("测试结果[爱奇艺兑换卡]：success");
    }

    private String queryUserMobile(String uId) {
        return "18720989281";
    }
}
